﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FixedVerticalSlider.cs" company="Marcelo Roca">
//   Copyright (c) 2011 Marcelo Roca. All rights reserved.
// </copyright>
// <author name="Marcelo Roca" email="marce@marceloroca.com"/>
// <license>
//   This program is free software: you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
// 
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program.  If not, see http://www.gnu.org/licenses/.
// </license>
// --------------------------------------------------------------------------------------------------------------------

namespace GameKits.Unity.GuiForms.Controls
{
    using System;
    using UnityEngine;

    /// <summary>
    /// A vertical slider the user can drag to change a value between a min and a max.
    /// </summary>
    public class FixedVerticalSlider : FixedControl
    {
        /// <summary>
        /// Se ejecuta cuando se modifica el valor del slider
        /// </summary>
        public event EventHandler ValueChanged;

        /// <summary>
        /// Gets or sets Value.
        /// </summary>
        /// <remarks>
        /// The value the slider shows. This determines the position of the draggable thumb.
        /// </remarks>
        public float Value { get; set; }

        /// <summary>
        /// Gets or sets TopValue.
        /// </summary>
        /// <remarks>
        /// The value at the top end of the slider
        /// </remarks>
        public float TopValue { get; set; }

        /// <summary>
        /// Gets or sets BottomValue.
        /// </summary>
        /// <remarks>
        /// The value at the bottom end of the slider
        /// </remarks>
        public float BottomValue { get; set; }

        /// <summary>
        /// Pintamos el control
        /// </summary>
        protected override void DrawControl()
        {
            //// TODO: add styles

            var val = GUI.VerticalSlider(
                this.PositionRect,
                this.Value,
                this.TopValue,
                this.BottomValue);

            if (val != this.Value)
            {
                this.Value = val;

                if (this.ValueChanged != null)
                {
                    this.ValueChanged(this, new EventArgs());
                }
            }
        }
    }
}
